﻿namespace XUCore.WeChat.Enterprise.Net.ServerMessages.From
{
    using Newtonsoft.Json;
    using System.Collections.Generic;
    using System.Xml.Serialization;
    using XUCore.WeChat.Net.ServerMessages.From;

    /// <summary>
    /// 企业客户标签创建事件
    /// </summary>
    [XmlRoot("xml")]
    public class FromChangeExternalTagCreateEvent : FromEventBase
    {
        /// <summary>
        /// Initializes a new instance of the <see cref="FromChangeExternalTagCreateEvent"/> class.
        /// </summary>
        public FromChangeExternalTagCreateEvent()
        {
            Event = FromEventTypes.change_external_tag;
            ChangeType = ChangeExternalTagChangeType.create;
        }

        /// <summary>
        /// 操作类型
        /// </summary>
        public ChangeExternalTagChangeType ChangeType { get; set; }

        /// <summary>
        /// 标签或标签组的ID
        /// </summary>
        [XmlElement("Id")]
        public string Id { get; set; }

        /// <summary>
        /// 创建标签时，此项为tag，创建标签组时，此项为tag_group
        /// </summary>
        [XmlElement("TagType")]
        public string TagType { get; set; }

        /// <summary>
        /// 标签或标签组所属的规则组id，只回调给“客户联系”应用
        /// </summary>
        [XmlElement("StrategyId")]
        public int StrategyId { get; set; }
    }


    /// <summary>
    /// 企业客户标签变更事件
    /// </summary>
    [XmlRoot("xml")]
    public class FromChangeExternalTagUpdateEvent : FromEventBase
    {
        /// <summary>
        /// Initializes a new instance of the <see cref="FromChangeExternalTagUpdateEvent"/> class.
        /// </summary>
        public FromChangeExternalTagUpdateEvent()
        {
            Event = FromEventTypes.change_external_tag;
            ChangeType = ChangeExternalTagChangeType.update;
        }

        /// <summary>
        /// 操作类型
        /// </summary>
        public ChangeExternalTagChangeType ChangeType { get; set; }

        /// <summary>
        /// 标签或标签组的ID
        /// </summary>
        [XmlElement("Id")]
        public string Id { get; set; }

        /// <summary>
        /// 变更标签时，此项为tag，变更标签组时，此项为tag_group
        /// </summary>
        [XmlElement("TagType")]
        public string TagType { get; set; }

        /// <summary>
        /// 标签或标签组所属的规则组id，只回调给“客户联系”应用
        /// </summary>
        [XmlElement("StrategyId")]
        public int StrategyId { get; set; }
    }


    /// <summary>
    /// 企业客户标签删除事件
    /// </summary>
    [XmlRoot("xml")]
    public class FromChangeExternalTagDeleteEvent : FromEventBase
    {
        /// <summary>
        /// Initializes a new instance of the <see cref="FromChangeExternalTagDeleteEvent"/> class.
        /// </summary>
        public FromChangeExternalTagDeleteEvent()
        {
            Event = FromEventTypes.change_external_tag;
            ChangeType = ChangeExternalTagChangeType.delete;
        }

        /// <summary>
        /// 操作类型
        /// </summary>
        public ChangeExternalTagChangeType ChangeType { get; set; }

        /// <summary>
        /// 标签或标签组的ID
        /// </summary>
        [XmlElement("Id")]
        public string Id { get; set; }

        /// <summary>
        /// 删除标签时，此项为tag，删除标签组时，此项为tag_group
        /// </summary>
        [XmlElement("TagType")]
        public string TagType { get; set; }

        /// <summary>
        /// 标签或标签组所属的规则组id，只回调给“客户联系”应用
        /// </summary>
        [XmlElement("StrategyId")]
        public int StrategyId { get; set; }
    }

    /// <summary>
    /// 企业客户标签重排事件
    /// </summary>
    [XmlRoot("xml")]
    public class FromChangeExternalTagShuffleEvent : FromEventBase
    {
        /// <summary>
        /// Initializes a new instance of the <see cref="FromChangeExternalTagShuffleEvent"/> class.
        /// </summary>
        public FromChangeExternalTagShuffleEvent()
        {
            Event = FromEventTypes.change_external_tag;
            ChangeType = ChangeExternalTagChangeType.shuffle;
        }

        /// <summary>
        /// 操作类型
        /// </summary>
        public ChangeExternalTagChangeType ChangeType { get; set; }

        /// <summary>
        /// 标签组的id，表示只有此标签组内的标签发生了重排，如果为空，则表示全部标签组顺序都发生了变化
        /// </summary>
        [XmlElement("Id")]
        public string Id { get; set; }

        /// <summary>
        /// 规则组id，如果修改了规则组标签的顺序，则回调时会带上此标签所属规则组的id
        /// </summary>
        [XmlElement("StrategyId")]
        public int StrategyId { get; set; }
    }

    public enum ChangeExternalTagChangeType
    {
        /// <summary>
        /// 企业客户标签创建事件
        /// </summary>
        create = 1,
        /// <summary>
        /// 企业客户标签变更事件
        /// </summary>
        update = 2,
        /// <summary>
        /// 企业客户标签删除事件
        /// </summary>
        delete = 3,
        /// <summary>
        /// 企业客户标签重排事件
        /// </summary>
        shuffle = 4,
    }
}
